package net.repchain.browser.common;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.util.StringUtils;

import java.io.Serializable;

/**
 * (WebPageInfo)实体类
 *
 * @author lhc
 * @since 2020-02-11 19:29:10
 */
@NoArgsConstructor
@AllArgsConstructor
@Builder(toBuilder = true)
@Data
public class WebPageInfo implements Serializable {

    private static final long serialVersionUID = 1156251348750279606L;

    public static final String DESC = "desc";
    public static final String ASC = "asc";


    private Integer pageSize = 10;


    private Integer pageNum = 1;

    private String sortField;


    private String order = ASC;

    public static boolean hasSort(WebPageInfo webPageInfo) {
        return StringUtils.hasLength(webPageInfo.getSortField());
    }

    public String getSortSql() {
        return this.sortField + " " + this.order;
    }
}
